﻿
Namespace LightSwitchApplication

    Public Class SubsidiaryLedgerByLocation

        Private Sub SubsidiaryLedgerByLocation_InitializeDataWorkspace(saveChangesTo As System.Collections.Generic.List(Of Microsoft.LightSwitch.IDataService))
            ' Write your code here.
            MainAssetsTablep_Location = Nothing
        End Sub

        Private Sub SubsidiaryLedgerByLocation_Created()
            Dim comboControl As IContentItemProxy = Me.FindControl("MainAssetsTablep_Location")
            comboControl.SetBinding(System.Windows.Controls.ComboBox.ItemsSourceProperty, "Screen.LocationsAll", System.Windows.Data.BindingMode.OneWay)
            comboControl.SetBinding(System.Windows.Controls.ComboBox.SelectedItemProperty, "Screen.MainAssetsTablep_Location", System.Windows.Data.BindingMode.TwoWay) ' Write your code here.

        End Sub

        Private Sub AllLocation_Execute()
            ' Write your code here.
            MainAssetsTablep_Location = Nothing
        End Sub

        Private Sub AssetsByLocation_Loaded(succeeded As Boolean)
            Me.SumAccumulatedDepreciation = Me.AssetsByLocation.Sum(Function(x) x.AccumulatedDepreciaton)
            Me.SumTotalCost = Me.AssetsByLocation.Sum(Function(x) If(x.AssetAmount > 0, x.AssetAmount, x.BaseCost + x.VAT))
            Me.NetBookValue = Me.SumTotalCost - Me.SumAccumulatedDepreciation
        End Sub
    End Class

End Namespace
